package com.yfyszk.kingbird.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfyszk.kingbird.common.utils.PageInfo;
import com.yfyszk.kingbird.common.utils.PageUtils;
import com.yfyszk.kingbird.feign.OrderFeignClient;
import com.yfyszk.kingbird.mapper.CouponMapper;
import com.yfyszk.kingbird.entity.CouponEntity;
import com.yfyszk.kingbird.service.ICouponService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import  com.yfyszk.kingbird.common.utils.Query;
import java.util.Map;

@Slf4j
@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponMapper, CouponEntity> implements ICouponService {

    @Autowired
    private CouponMapper couponMapper;
    @Override
    public String testFfeign() {
        return "请求成功";
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CouponEntity> page = this.page(
                new Query<CouponEntity>().getPage(params),
                new QueryWrapper<CouponEntity>()
        );
        log.info("queryPage:{}",page);
        return new PageUtils(page);
    }

    @Override
    public PageUtils listzdyPage(PageInfo pageInfo) {
        Page<CouponEntity> page = new Page<CouponEntity>(pageInfo.getCurrent(), pageInfo.getLimit());
        IPage<CouponEntity> all = this.baseMapper.listzdyPage(page);
        return new PageUtils(all);
    }



}